package com.wyzz.hr.pojo.base;

import com.wyzz.hr.base.BaseDomain;
import com.wyzz.hr.bo.IEmployeeBo;
import com.wyzz.hr.pojo.Department;
import com.wyzz.hr.pojo.Employee;
import com.wyzz.hr.pojo.Empsalarypay;
import com.wyzz.hr.pojo.base.base.BaseBean;
import com.wyzz.hr.spring.SpringBeanFactory;

import java.io.Serializable;
import java.util.*;

public abstract class BaseDepartment extends BaseDomain implements Serializable {

	public BaseDepartment() {
		hashCode = 0x80000000;
		initialize();
	}

	public BaseDepartment(String id) {
		hashCode = 0x80000000;
		setId(id);
		initialize();
	}

	public BaseDepartment(String id, String departmentName,
			Integer departmentSortId) {
		hashCode = 0x80000000;
		setId(id);
		setDepartmentName(departmentName);
		setDepartmentSortId(departmentSortId);
		initialize();
	}

	protected void initialize() {
	}

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
		hashCode = 0x80000000;
	}

	public String getDepartmentName() {
		return departmentName;
	}

	public void setDepartmentName(String departmentName) {
		this.departmentName = departmentName;
	}

	public String getDepartmentDesc() {
		return departmentDesc;
	}

	public void setDepartmentDesc(String departmentDesc) {
		this.departmentDesc = departmentDesc;
	}

	public Integer getDepartmentSortId() {
		return departmentSortId;
	}

	public void setDepartmentSortId(Integer departmentSortId) {
		this.departmentSortId = departmentSortId;
	}

	public Set getEmpsalarypaids() {
		return empsalarypaids;
	}

	public void setEmpsalarypaids(Set empsalarypaids) {
		this.empsalarypaids = empsalarypaids;
	}

	public void addToempsalarypaids(Empsalarypay empsalarypaid) {
		if (null == getEmpsalarypaids())
			setEmpsalarypaids(new TreeSet());
		getEmpsalarypaids().add(empsalarypaid);
	}

	public Set getEmployees() {
		return employees;
	}

	public void setEmployees(Set employees) {
		this.employees = employees;
	}

	public void addToemployees(Employee employee) {
		if (null == getEmployees())
			setEmployees(new TreeSet());
		getEmployees().add(employee);
	}

	public boolean equals(Object obj) {
		if (null == obj)
			return false;
		if (!(obj instanceof Department))
			return false;
		Department department = (Department) obj;
		if (null == getId() || null == department.getId())
			return false;
		else
			return getId().equals(department.getId());
	}

	public int hashCode() {
		if (0x80000000 == hashCode) {
			if (null == getId())
				return super.hashCode();
			String hashStr = (new StringBuilder()).append(getClass().getName())
					.append(":").append(getId().hashCode()).toString();
			hashCode = hashStr.hashCode();
		}
		return hashCode;
	}

	public String toString() {
		return super.toString();
	}

	public String getDepartmentHead() {
		if (getId() == null)
			return null;
		IEmployeeBo empBo = (IEmployeeBo) SpringBeanFactory.getBean("empBo");
		String hql = (new StringBuilder()).append(
				"SELECT orgheadsEmpNo from Orgheads where orgheadsOrgNo ='")
				.append(getId()).append(
						"' and orgheadsResponsibility='deptheader'").toString();
		List list = empBo.exeHqlList(hql, new int[0]);
		if (list == null || list.size() == 0)
			return null;
		else
			return (String) list.get(0);
	}

	public String getDepartmentOtherHeads() {
		if (getId() == null)
			return null;
		IEmployeeBo empBo = (IEmployeeBo) SpringBeanFactory.getBean("empBo");
		String hql = (new StringBuilder()).append(
				"SELECT orgheadsEmpNo from Orgheads where orgheadsOrgNo ='")
				.append(getId()).append(
						"' and orgheadsResponsibility='deptdeputy'").toString();
		List list = empBo.exeHqlList(hql, new int[0]);
		if (list == null || list.size() == 0)
			return null;
		String result = (String) list.get(0);
		for (int i = 1; i < list.size(); i++)
			result = (new StringBuilder()).append(result).append(",").append(
					(String) list.get(i)).toString();

		return result;
	}

	public String getHeadNo() {
		return headNo;
	}

	public void setHeadNo(String headNo) {
		this.headNo = headNo;
	}

	public String getHeadName() {
		return headName;
	}

	public void setHeadName(String headName) {
		this.headName = headName;
	}

	public Integer getDepartmentStatus() {
		return departmentStatus;
	}

	public void setDepartmentStatus(Integer departmentStatus) {
		this.departmentStatus = departmentStatus;
	}

	public Integer getDepartmentCate() {
		return departmentCate;
	}

	public void setDepartmentCate(Integer departmentCate) {
		this.departmentCate = departmentCate;
	}

	public String getDepartmentBusinessDesc() {
		return departmentBusinessDesc;
	}

	public void setDepartmentBusinessDesc(String departmentBusinessDesc) {
		this.departmentBusinessDesc = departmentBusinessDesc;
	}

	public String getDepartmentBusinessAttach() {
		return departmentBusinessAttach;
	}

	public void setDepartmentBusinessAttach(String departmentBusinessAttach) {
		this.departmentBusinessAttach = departmentBusinessAttach;
	}

	public String getDepartmentTrade() {
		return departmentTrade;
	}

	public void setDepartmentTrade(String departmentTrade) {
		this.departmentTrade = departmentTrade;
	}

	public String getDepartmentMemo() {
		return departmentMemo;
	}

	public void setDepartmentMemo(String departmentMemo) {
		this.departmentMemo = departmentMemo;
	}

	public String getDepartmentPersonInlaw() {
		return departmentPersonInlaw;
	}

	public void setDepartmentPersonInlaw(String departmentPersonInlaw) {
		this.departmentPersonInlaw = departmentPersonInlaw;
	}

	public Department getDepartmentParentId() {
		return departmentParentId;
	}

	public void setDepartmentParentId(Department departmentParentId) {
		this.departmentParentId = departmentParentId;
	}

	public Date getDepartmentCreateDate() {
		return departmentCreateDate;
	}

	public void setDepartmentCreateDate(Date departmentCreateDate) {
		this.departmentCreateDate = departmentCreateDate;
	}

	public Date getDepartmentEndDate() {
		return departmentEndDate;
	}

	public void setDepartmentEndDate(Date departmentEndDate) {
		this.departmentEndDate = departmentEndDate;
	}

	public static String REF = "Department";
	public static String PROP_DEPARTMENT_SORT_ID = "departmentSortId";
	public static String PROP_DEPARTMENT_NAME = "departmentName";
	public static String PROP_DEPARTMENT_DESC = "departmentDesc";
	public static String PROP_ID = "id";
	public static String PROP_DEPARTMENT_STATUS = "departmentStatus";
	public static String PROP_DEPARTMENT_PARENT_ID = "departmentParentId";
	public static String PROP_DEPARTMENT_CATE = "departmentCate";
	public static String PROP_DEPARTMENT_BUSINESS_DESC = "departmentBusinessDesc";
	public static String PROP_DEPARTMENT_BUSINESS_ATTACH = "departmentBusinessAttach";
	public static String PROP_DEPARTMENT_CREATE_TIME = "departmentCreateDate";
	public static String PROP_DEPARTMENT_END_TIME = "departmentEndDate";
	public static String PROP_DEPARTMENT_TRADE = "departmentTrade";
	public static String PROP_DEPARTMENT_PERSONINLAW = "departmentPersonInlaw";
	public static String PROP_DEPARTMENT_MEMO = "departmentMemo";
	private int hashCode;
	private String id;
	private String departmentName;
	private String departmentDesc;
	private Integer departmentSortId;
	private Integer departmentStatus;
	private Integer departmentCate;
	private String departmentBusinessDesc;
	private String departmentBusinessAttach;
	private Date departmentCreateDate;
	private Date departmentEndDate;
	private String departmentTrade;
	private String departmentPersonInlaw;
	private String departmentMemo;
	private Department departmentParentId;
	public String headNo;
	public String headName;
	private Set empsalarypaids;
	private Set employees;

}
